package com.heyqing.topic.WordPattern_0290;

import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * ClassName:WordPattern
 * Package:com.heyqing.topic.WordPattern_0290
 * Description:
 *
 * @Date:2024/9/26
 * @Author:Heyqing
 */
public class WordPattern {
    public boolean wordPattern(String pattern, String s) {
        String[] strs = s.split("\\s+");
        List<String> list = Arrays.asList(strs);
        if (strs.length != pattern.length()) return false;
        for (int i = 0; i < strs.length; i++) {
            if (pattern.indexOf(String.valueOf(pattern.charAt(i))) != list.indexOf(list.get(i))) return false;
        }
        return true;
    }
}
